<ui:composition template="/admin/templates/ui2.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:composite="http://java.sun.com/jsf/composite/primefaces"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:fn="http://java.sun.com/jsp/jstl/functions"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:sec="http://www.springframework.org/security/facelets/tags">

    <ui:define name="content">
    	<div class="entry">
    	<p:toolbar>
            <p:toolbarGroup>
	            <h:outputLabel style="padding-left: 15px;" value="#{commonMsg.currentPositionLabel}#{userMsg.roleManagerLabel}"></h:outputLabel>
            </p:toolbarGroup>
            <p:toolbarGroup align="right">
	            <p:separator />  
	            <p:button value="#{userMsg.addRoleLabel}" outcome="/admin/user/roleEdit"></p:button>
            </p:toolbarGroup>
        </p:toolbar>
        <h:form id="form"> 

			<p:spacer></p:spacer> 
                
                <p:panel id="filters">
                    <h:inputText id="searchId" value="#{roleList.example.id}"></h:inputText>
                    <h:inputText id="searchTitle" value="#{roleList.example.name}"></h:inputText>
                    <p:commandButton update="dataTable" process="filters"
                        value="#{commonMsg.searchLabel}"></p:commandButton>
                </p:panel>
                <p:watermark for="searchId" value="#{commonMsg.IDLabel}" />  
                <p:watermark for="searchTitle" value="#{userMsg.roleLabel}"></p:watermark>
            
            <p:spacer></p:spacer> 
          
            <p:dataTable lazy="true" id="dataTable" value="#{roleList.lazyModel}" var="role" 
                paginator="true" paginatorPosition="bottom" rows="15" currentPageReportTemplate="#{commonMsg.pageReportTemplate}"
                paginatorTemplate="#{commonMsg.paginatorTemplate}" rowsPerPageTemplate="15,50,100"
                emptyMessage="#{commonMsg.noResultMsg}">
                <p:column headerText="#{commonMsg.IDLabel }" sortBy="role.id" style="width:250px;">
                    <h:outputText  value="#{role.id}"></h:outputText>
                </p:column>
                <p:column headerText="#{commonMsg.nameLabel}" sortBy="role.name" >
                    <h:outputText  value="#{role.name}"></h:outputText>
                </p:column>
                <p:column headerText="#{commonMsg.descriptionLabel}" >
                    <h:outputText  value="#{role.description}"></h:outputText>
                </p:column>
                <p:column headerText="#{commonMsg.actionLabel}">
                    <h:link value="#{commonMsg.editLabel}" outcome="/admin/user/roleEdit?id=#{role.id}"></h:link> |
                    <a href="javascript:void(0)" onclick="$('#form\\:deleteId').val('#{role.id}');confirmDialog.show()">#{commonMsg.deleteLabel}</a> 
                </p:column>
                <f:facet name="footer"> 
						<p:commandButton value="导出Excel" ajax="false">
							<p:dataExporter target="dataTable" type="xls" 
								fileName="roleList" pageOnly="false"></p:dataExporter>
						</p:commandButton>
	 		        </f:facet>
            </p:dataTable>
            <p:confirmDialog width="500" id="confirmDialog" widgetVar="confirmDialog" severity="alert" header="#{commonMsg.confirmDetele}" message="#{userMsg.deleteRoleInfo}">
                <h:inputHidden value="#{roleHome.id}" id="deleteId"></h:inputHidden>
                    <p:commandButton id="confirm" value="#{commonMsg.confirmLabel}" action="#{roleHome.delete}" ajax="false" style="margin-left:180px;" />  
                    <p:commandButton id="decline" value="#{commonMsg.cancelLabel}" onclick="confirmDialog.hide()" type="button" />
            </p:confirmDialog>
        </h:form>
       </div>
    </ui:define>
</ui:composition>
